package common.inter;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

import common.kit.PropKits;

public class CorsInter implements Interceptor{

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController() ;
		if (PropKits.isDevMode()) {
			controller.getResponse().setHeader("Access-Control-Allow-Origin", "*");
		}
		controller.getResponse().addHeader("Access-Control-Allow-Credentials", "true");
		controller.getResponse().addHeader("Access-Control-Allow-Methods","POST,GET"); //使用通配符
		controller.getResponse().addHeader("Access-Control-Allow-Headers","*");  //使用通配符
		inv.invoke();
	}

}
